import random

phone_prefixes = ["133", "149", "153", "173", "177", "180", "181", "189", "190", "191", "193",
                  "199", "130", "131", "132", "145", "155", "156", "166", "167", "171", "175",
                  "176", "185", "186", "196", "134", "135", "136", "137", "138", "139", "144",
                  "147", "148", "150", "151", "152", "157", "158", "159", "172", "178", "182",
                  "183", "184", "187", "188", "195", "197", "198", "170", "174"]

# A-Z: 65-90, a-z:97-122, 下划线：95, 数字：48-57
password_ranges = [range(65, 91), range(97, 123), range(95, 96), range(48, 58)]


def generateAcount(n: int):
    dicts = []
    phone_set = set() #号码去重
    password_set = set() #密码去重
    while len(dicts) < n:
        phone = generatePhone()
        pwd = generatePassword()
        if phone not in phone_set and pwd not in password_set:
            phone_set.add(phone)
            password_set.add(pwd)
            dicts.append({"phone": phone, "passord": pwd})
    return dicts

def generatePhone():
    phone = random.choice(phone_prefixes) #号码前缀
    for i in range(0, 8):
        phone = phone + chr(random.randint(48, 57))
    return phone

def generatePassword():
    count = random.randint(8, 16) #密码位数
    pwd = ''
    for i in range(0, count):
        bound = random.choice(password_ranges)
        ascii = random.choice(bound)
        pwd = pwd + chr(ascii)
    return pwd

print(generateAcount(3))